package com.swt.controller.W_controller;

import com.alibaba.fastjson.JSON;
import com.swt.service.W_service.StatsService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 数据统计
 * */
@Controller
@RequestMapping("/StatsController")
public class StatsController {
    @Resource
    private StatsService statsService;



    @RequestMapping("/countUser")
    @ResponseBody
    public String countUser(){
        //用户每月注册人数统计
        List list= statsService.countUser();
        //商家每月注册人数统计
        List list1=statsService.countClub();

        Map<String,List> map=new HashMap<>();

        map.put("user",list);
        map.put("club",list1);


        System.out.println("controllerList:===="+map);
        return JSON.toJSONString(map);
    }


    /**
     *首页统计表
     * */
    @RequestMapping("/countAll")
    @ResponseBody
    public String countAll(){

        //用户今日注册人数
        List list1=statsService.countUserDay();
        //用户昨日注册人数
        List list2=statsService.countUserYesterday();
        //用户本周注册人数
        List list3=statsService.countUserWeek();
        //用户本月注册人数
        List list4=statsService.countUserMonth();
        //用户总注册人数
        List list9=statsService.countUserAll();


        //商家今日注册人数
        List list5=statsService.countClubDay();
        //商家昨日注册人数
        List list6=statsService.countClubYesterday();
        //商家本周注册人数
        List list7=statsService.countClubWeek();
        //商家本月注册人数
        List list8=statsService.countClubMonth();
        //商家总注册人数
        List list10=statsService.countClubAll();

        Map<String,List> map=new HashMap<>();

        map.put("userToday",list1);
        map.put("userYesterday",list2);
        map.put("userWeek",list3);
        map.put("userMonth",list4);
        map.put("clubToday",list5);
        map.put("clubYesterday",list6);
        map.put("clubWeek",list7);
        map.put("clubMonth",list8);
        map.put("userAll",list9);
        map.put("clubAll",list10);


        return JSON.toJSONString(map);

    }

}
